fix: accept quoted numeric strings in OrganizationCostsResult.Amount.value() (#769)#771
Open
kuntal1461 wants to merge 1 commit into
Open
fix: accept quoted numeric strings in OrganizationCostsResult.Amount.value() (#769)#771kuntal1461 wants to merge 1 commit into
kuntal1461 wants to merge 1 commit into
Conversation
…value() (openai#769) The live API returns `OrganizationCostsResult.Amount.value` as a quoted numeric string (e.g. "0E-6176") despite the OpenAPI spec declaring `type: number`. Jackson's CoercionAction.Fail for String→Float causes tryDeserialize to return null, leaving a JsonString in the JsonField which getOptional() then rejects as invalid data. Fix adds a BigDecimal fallback in Amount.value(): if asKnown() is absent and the backing field is a JsonString, parse via BigDecimal → Double with an isFinite() guard to reject overflow. Authored-By: Kuntal maity <kuntal.1461@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
OrganizationCostsResult.Amount.value()threwOpenAIInvalidDataExceptionwhen the live API returnedamount.valueas a quoted numeric string (e.g."0E-6176") despite the OpenAPI spec declaringtype: numberCoercionAction.FailforString→FloatcausedtryDeserializeto returnnullfor quoted numeric strings, leaving aJsonStringin theJsonFieldwhichgetOptional()rejected as invalidAmount.value(): ifasKnown()is absent and the backing field is aJsonString, parse viaBigDecimal→Doublewith anisFinite()guard to reject overflowTest plan
quoted 0E-6176 zero-cost string returns 0.0— primary bug reproduction verified locallyOpenAIInvalidDataException"1e309") rejected byisFinite()guardvalidate()benefits automatically (callsvalue()internally)Authored-By: Kuntal maity kuntal.1461@gmail.com